<%@ page language="VB" masterpagefile="~/masterpages/MasterPrivateEval.master" autoeventwireup="false" CodeFile="AvaluacionsShow.aspx.vb" inherits="rrhh_AvaluacionsShow" meta:resourcekey="PageResource1" stylesheettheme="EVIGreenES" %>
<%@ Register Assembly="RadWindow.Net2" Namespace="Telerik.WebControls" TagPrefix="radW" %>
<%@ Register Assembly="RadGrid.Net2" Namespace="Telerik.WebControls" TagPrefix="radG" %>
<%@ Register Assembly="RadComboBox.Net2" Namespace="Telerik.WebControls" TagPrefix="radcb" %>
<%@ Register Assembly="RadAjax.Net2" Namespace="Telerik.WebControls" TagPrefix="radA" %>
<%@ Register Assembly="RadInput.Net2" Namespace="Telerik.WebControls" TagPrefix="radI" %>

<asp:Content ID="Content1" ContentPlaceHolderID="PrivateWorkArea" runat="Server">
   <script type="text/javascript">
    function confirmationcopy() {
        var message = 'Es copiaran les avaluacions del any anterior. Vol continuar?';
        if (confirm(message)) {
            return true;
        } else {
            return false;
        }
    }
    function confirmationlock() {
        var message = 'Es bloquejaran/desbloquejaran totes les avaluacions. Vol continuar?';
        if (confirm(message)) {
            return true;
        } else {
            return false;
        }
    }
    </script>
    <table cellpadding="0" cellspacing="0" border="0" width="98%" align="center">
        <tr valign="top">
           <td>
                <div class="bgpanel_title"><asp:Label ID="lblTituloForm" runat="server" Text="<%$ Resources:lblTituloForm %>"></asp:Label></div>
                <div class="bgpanelFV">
                    <br />
                    <fieldset style="width:99%;padding-left:0px;margin-left:0px">
                        <legend><asp:Label ID="Label14" runat="server" Text="<%$ Resources:lblLegendFiltros %>"></asp:Label></legend>
                        <table width="90%" cellpadding="1" cellspacing="0" border="0">
                            <tr>
                                <td style="width:200px;text-align:right">
                                    <asp:Label ID="lblFiltroAnyo" runat="server" Text="<%$ Resources:lblFiltroAnyo %>" SkinID="LiteralesVerdeOscuro"></asp:Label>
                                </td>
                                <td style="width:10px">&nbsp;</td>
                                <td style="text-align:left;width:150px">
                                    <radcb:radcombobox runat="server" id="ddlEjercicios" Skin="WindowsOliveCenter" Width="100px"
                                           DataSourceID="SqlDataSourceAnyos" 
                                           DataTextField="Anyo" 
                                           DataValueField="Anyo"
                                           OnSelectedIndexChanged="ddlEjercicios_SelectedIndexChanged"
                                           AppendDataBoundItems="False"
                                           AutoPostBack="True">
                                    </radcb:radcombobox>                                     
                                </td>
                                <td width="60%">&nbsp;</td>
                            </tr> 
                            <tr>
                                <td style="width:200px;text-align:right">
                                    <asp:Label ID="lblFiltroEvaluador" runat="server" Text="<%$ Resources:lblFiltroEvaluador %>" SkinID="LiteralesVerdeOscuro"></asp:Label>
                                </td>
                                <td style="width:10px">&nbsp;</td>
                                <td style="text-align:left;width:200px">
                                    <radcb:radcombobox runat="server" id="ddlEvaluadores" Skin="WindowsOliveCenter" Width="150px"
                                           DataSourceID="SqlDataSourceEvaluadores" 
                                           DataTextField="UsuarioEvaluador" 
                                           DataValueField="idUsuarioEvaluador"
                                           OnSelectedIndexChanged="ddlEvaluadores_SelectedIndexChanged"
                                           AppendDataBoundItems="False"
                                           AutoPostBack="True">
                                    </radcb:radcombobox>                                     
                                </td>
                                <td width="60%">&nbsp;</td>
                            </tr> 
                            <tr>
                                <td style="width:200px;text-align:right">
                                    <asp:Label ID="LblFiltroMotivo" runat="server" Text="<%$ Resources:lblFiltroMotivo %>" SkinID="LiteralesVerdeOscuro"></asp:Label>
                                </td>
                                <td style="width:10px">&nbsp;</td>
                                <td style="text-align:left;width:200px">
                                    <radcb:radcombobox runat="server" id="ddlMotivos" Skin="WindowsOliveCenter" Width="150px"
                                           DataSourceID="SqlDataSourceMotivos" 
                                           DataTextField="Motivo" 
                                           DataValueField="Motivo"
                                           OnSelectedIndexChanged="ddlMotivos_SelectedIndexChanged"
                                           AppendDataBoundItems="False"
                                           AutoPostBack="True">
                                    </radcb:radcombobox>                                     
                                </td>
                                <td width="60%">&nbsp;</td>
                            </tr> 
                            <tr>
                                <td style="width:200px;text-align:right">
                                    <asp:Label ID="lblFiltroEvaluado" runat="server" Text="<%$ Resources:lblFiltroEvaluado %>" SkinID="LiteralesVerdeOscuro"></asp:Label>
                                </td>
                                <td style="width:10px">&nbsp;</td>
                                <td style="text-align:left;width:200px">
                                    <asp:TextBox runat="server" id="txtFiltroEvaluado" SkinID="Campos" Width="130px" ReadOnly="false">
                                    </asp:TextBox>
                                    <asp:Button runat="server" ID="btnFiltrarEvaluado" CssClass="BtnStaBuscar" OnClick="btnFiltrarEvaluado_Click" ToolTip="Filtrar" />
                                </td>
                                <td width="60%">&nbsp;</td>
                            </tr> 
                        </table>
                    </fieldset>
                    <br /><br />                                           
                    <radG:RadGrid ID="GridEvaluaciones" runat="server"
                                  Skin="Office2007"
                                  DataSourceID="SqlDataSourceEvaluaciones"
                                  AutoGenerateColumns="False"
                                  AllowMultiRowSelection="False"
                                  Width="100%"
                                  AllowSorting="True"
                                  AllowPaging="True"
                                  PageSize="30"
                                  AllowMultiRowEdit="False"
                                  GroupingEnabled="True"
                                  ShowGroupPanel="False"
                                  AllowFilteringByColumn="False"
                                  EnableAJAX="True"
                                  EnableAJAXLoadingTemplate="True"                                   
                                  GridLines="None"
                                  AllowAutomaticDeletes="True"
                                  AllowAutomaticInserts="False"
                                  AllowAutomaticUpdates="False"
                                  GroupingSettings-ExpandTooltip="<%$ Resources:GridGroupingExpandToolTip %>"
                                  GroupingSettings-CollapseTooltip="<%$ Resources:GridGroupingCollapseToolTip %>"                                  
                                  HierarchySettings-ExpandTooltip="<%$ Resources:GridGroupingExpandToolTip %>"
                                  HierarchySettings-CollapseTooltip="<%$ Resources:GridGroupingCollapseToolTip %>"
                                  SortingSettings-SortToolTip="<%$ Resources:GridSortToolTip %>"
                                  SortingSettings-SortedAscToolTip="<%$ Resources:GridSortedAscToolTip %>"
                                  SortingSettings-SortedDescToolTip="<%$ Resources:GridSortedDescToolTip %>"
                                  ActiveItemStyle-Font-Bold="True"
                                  LicenseFile="~/RadControls/LicenseFile.xml"
                                  >
                        <PagerStyle Mode="NumericPages" PagerTextFormat="<%$ Resources:GridPagerTextFormat %>" AlwaysVisible="False" CssClass="GridPager_Office2007" />                                              
                        <ClientSettings ReorderColumnsOnClient="False" AllowColumnsReorder="False" Selecting-AllowRowSelect="True">
                            <Resizing AllowRowResize="False" ClipCellContentOnResize="False" AllowColumnResize="False">
                            </Resizing>
                            <ClientMessages DragToResize="<%$ Resources:GridDragToResize %>"  />                           
                        </ClientSettings>
                                                
                        <MasterTableView DataSourceID="SqlDataSourceEvaluaciones" DataKeyNames="idEvaluacion" AllowMultiColumnSorting="True" CommandItemDisplay="Top" HorizontalAlign="NotSet" AutoGenerateColumns="False">
                           <NoRecordsTemplate>
                                <asp:Label ID="lblMasterNoRecords" runat="server" Text="<%$ Resources:GridMasterNoRecords %>"></asp:Label>                               
                           </NoRecordsTemplate> 
                           <CommandItemTemplate>
                                  <table width="100%">
                                   <tr>
                                    <td style="width:25%">                                     
                                     <asp:Button ID="btnAdd"  CssClass="BtnGridAnyadir" Text="<%$ Resources:GridMasterCommandItemAdd %>" CommandName="Alta" Runat="server"></asp:Button>
                                    </td>
                                    <td style="width:20%">                                     
                                     <asp:Button ID="btnCopiar"  CssClass="BtnGridCopiar" Text="<%$ Resources:GridMasterCommandItemCopy %>" OnClientClick="return confirmationcopy();" CommandName="Copiar" OnClick="btnCopiar_Click" Runat="server"></asp:Button>
                                    </td>
                                    <td style="width:15%; text-align:right">                                     
                                     <asp:Button ID="btnLock"  CssClass="BtnGridLock" Text="<%$ Resources:GridMasterCommandItemLock %>" CommandName="Bloquear" Runat="server"></asp:Button>
                                    </td>
                                    <td style="width:15%">                                     
                                     <asp:Button ID="btnUnLock"  CssClass="BtnGridUnLock" Text="<%$ Resources:GridMasterCommandItemUnLock %>" CommandName="Desbloquear" Runat="server"></asp:Button>
                                    </td>                                    
                                    <td style="width:25%; text-align:right">
                                     <asp:Button ID="btnRefresh" CssClass="BtnGridRefrescar" Text="<%$ Resources:GridMasterCommandItemRefresh %>" CommandName="Rebind" Runat="server"></asp:Button>
                                    </td>
                                   </tr>
                                  </table>
                            </CommandItemTemplate>
                            <GroupByExpressions>
                                <radG:GridGroupByExpression>
                                    <SelectFields>
                                        <radG:GridGroupByField FieldAlias="idUsuarioEvaluador" FieldName="idUsuarioEvaluador" HeaderText="<%$ Resources:GridMasterHeaderEvaluador %>"></radG:GridGroupByField>
                                    </SelectFields>
                                    <GroupByFields>
                                        <radG:GridGroupByField FieldAlias="idUsuarioEvaluador" FieldName="idUsuarioEvaluador" HeaderText="<%$ Resources:GridMasterHeaderEvaluador %>" ></radG:GridGroupByField>
                                    </GroupByFields>
                                </radG:GridGroupByExpression>
                            </GroupByExpressions>                            
                            <Columns>
                                <radG:GridButtonColumn UniqueName="EditColumn" ButtonType="ImageButton" ShowSortIcon="False" ImageUrl="..\Images\ImgGrids\Edit.gif" CommandName="Editar" HeaderStyle-HorizontalAlign="Center" Text="<%$ Resources:GridEditCommandEdit %>">
                                    <ItemStyle CssClass="ImageBtnPointer" HorizontalAlign="Center" />
                                </radG:GridButtonColumn>
                                <radG:GridBoundColumn UniqueName="idEvaluacion" DataField="idEvaluacion" HeaderText="ID" ReadOnly="True" Visible="False">
                                </radG:GridBoundColumn>                                
                                <radG:GridBoundColumn UniqueName="idCliente" DataField="idCliente" HeaderText="" ReadOnly="True" Visible="False">
                                </radG:GridBoundColumn>                                          
                                <radG:GridBoundColumn UniqueName="idUsuarioEvaluador" DataField="idUsuarioEvaluador" HeaderText="<%$ Resources:GridMasterHeaderEvaluador %>" ReadOnly="True" Visible="False"
                                    ItemStyle-HorizontalAlign="Left" HeaderStyle-Width="40%">
                                </radG:GridBoundColumn>                             
                                <radG:GridBoundColumn UniqueName="UsuarioEvaluado" DataField="UsuarioEvaluado" HeaderText="<%$ Resources:GridMasterHeaderEvaluado %>" ReadOnly="True" Visible="True"
                                    ItemStyle-HorizontalAlign="Left" HeaderStyle-Width="40%">
                                </radG:GridBoundColumn>
                                <radG:GridBoundColumn UniqueName="AnyoEvaluacion" DataField="AnyoEvaluacion" HeaderText="<%$ Resources:GridMasterHeaderAnyoEvaluacion %>" ReadOnly="True" Visible="True"
                                    ItemStyle-HorizontalAlign="Center" HeaderStyle-Width="10%">
                                </radG:GridBoundColumn>
                                <radG:GridBoundColumn UniqueName="PuestoTrabajo" DataField="PuestoTrabajo" HeaderText="<%$ Resources:GridMasterHeaderPuestoTrabajo %>" ReadOnly="True" Visible="True"
                                    ItemStyle-HorizontalAlign="Left" HeaderStyle-Width="20%">
                                </radG:GridBoundColumn>
                                <radG:GridBoundColumn UniqueName="Motivo" DataField="Motivo" HeaderText="<%$ Resources:GridMasterHeaderMotivo %>" ReadOnly="True" Visible="True"
                                    ItemStyle-HorizontalAlign="Left" HeaderStyle-Width="20%">
                                </radG:GridBoundColumn>
                                <radG:GridCheckBoxColumn UniqueName="IndBloqueada" DataField="IndBloqueada" HeaderText="<%$ Resources:GridMasterHeaderBloqueada %>" ReadOnly="true" Visible="true"
                                    ItemStyle-HorizontalAlign="Center" HeaderStyle-Width="10%">                                    
                                </radG:GridCheckBoxColumn>
                                <radG:GridButtonColumn UniqueName="CopyColumn" ButtonType="ImageButton" ShowSortIcon="False" ImageUrl="..\Images\ImgGrids\Copy.gif" CommandName="Copiar" Text="<%$ Resources:GridMasterButtonCopyText %>" ItemStyle-HorizontalAlign="Center">
                                    <HeaderStyle Width="20px" />
                                    <ItemStyle HorizontalAlign="Center" CssClass="ImageBtnPointer" />                                    
                                </radG:GridButtonColumn>
                                <radG:GridButtonColumn ConfirmText="<%$ Resources:GridMasterButtonDeleteConfirm %>" ButtonType="ImageButton" ImageUrl="..\Images\ImgGrids\Delete.gif" CommandName="Delete" Text="<%$ Resources:GridMasterButtonDeleteText %>" UniqueName="DeleteColumn">
                                    <HeaderStyle Width="20px" />
                                    <ItemStyle HorizontalAlign="Center" CssClass="ImageBtnPointer" />
                                </radG:GridButtonColumn>
                            </Columns>
                           <SortExpressions>
                                <radG:GridSortExpression FieldName="idUsuarioEvaluador,UsuarioEvaluado,AnyoEvaluacion" />
                           </SortExpressions>
                        </MasterTableView>
                        <AJAXLoadingTemplate>
                            <img src="../images/LoadingProgressBar.gif" alt="Cargando Datos" align="middle" />
                        </AJAXLoadingTemplate>                        
                    </radG:RadGrid>
                </div>
                <div class="bgpanel_bottom">
                    <table cellpadding="0" cellspacing="0" border="0">
                        <tr>
                            <td style="width: 85px" valign="top">
                                <asp:Image ID="imgButtonIconDocuments" runat="server" ImageUrl="../images/button_icon_eval_config.gif"
                                    Height="57px" meta:resourcekey="imgButtonIconUsersResource1" />
                            </td>
                            <td align="left" valign="top" class="bgpanel_buttons">
                            </td>
                            <td align="right" valign="top" class="bgpanel_buttons">
                            </td>
                        </tr>
                    </table>
                </div>                    
           </td>
        </tr>
    </table> 
    <asp:Label ID="LabelError" runat="server" Text="" SkinID="msgerror"></asp:Label>              
    
    
    <asp:SqlDataSource ID="SqlDataSourceEvaluaciones" runat="server" ConnectionString="<%$ ConnectionStrings:EviMaster %>"
        Selectcommand="Select * From vw_evi_EvaluacionesFinales WHERE ([idCliente] = @idCliente) And ([AnyoEvaluacion] = @AnyoEvaluacion) And (idUsuarioEvaluador = @idUsuarioEvaluador)"
        DeleteCommand="spEvaluacionesDelete" DeleteCommandType="StoredProcedure">
        <SelectParameters>
            <asp:ProfileParameter Name="idCliente" PropertyName="cliente" />
            <asp:ControlParameter ControlID="ddlEjercicios" Name="AnyoEvaluacion" />       
            <asp:ControlParameter ControlID="ddlEvaluadores" Name="idUsuarioEvaluador" />   
            <asp:ControlParameter ControlID="ddlMotivos" Name="Motivo" />
        </SelectParameters>
        <DeleteParameters>
          <asp:Parameter Name="idEvaluacion"/>
        </DeleteParameters>        
    </asp:SqlDataSource>
    
    <asp:SqlDataSource ID="SqlDataSourceAnyos" runat="server" ConnectionString="<%$ ConnectionStrings:EviMaster %>"
        SelectCommand="SELECT DISTINCT AnyoEvaluacion As Anyo From Evaluaciones where ([idCliente] = @idCliente) union select year(getdate())" >
        <SelectParameters>
            <asp:ProfileParameter Name="idCliente" PropertyName="cliente" />
        </SelectParameters>
    </asp:SqlDataSource>

    <asp:SqlDataSource ID="SqlDataSourceEvaluadores" runat="server" ConnectionString="<%$ ConnectionStrings:EviMaster %>"
        SelectCommand="SELECT DISTINCT idUsuarioEvaluador, name as UsuarioEvaluador From Evaluaciones inner join UserNames on (idUsuarioEvaluador = username) where ([idCliente] = @idCliente) union select '-','-'" >
        <SelectParameters>
            <asp:ProfileParameter Name="idCliente" PropertyName="cliente" />
        </SelectParameters>
    </asp:SqlDataSource>

    <asp:SqlDataSource ID="SqlDataSourceMotivos" runat="server" ConnectionString="<%$ ConnectionStrings:EviMaster %>"
        SelectCommand="SELECT DISTINCT Motivo From Evaluaciones where ([idCliente] = @idCliente) union select '-'" >
        <SelectParameters>
            <asp:ProfileParameter Name="idCliente" PropertyName="cliente" />
        </SelectParameters>
    </asp:SqlDataSource>
    
  <radA:RadAjaxManager ID="AjaxManager1" runat="server" EnableAJAX="True">
    <AjaxSettings>
        <radA:AjaxSetting AjaxControlID="ddlEjercicios">
            <UpdatedControls>
                <radA:AjaxUpdatedControl ControlID="GridEvaluaciones" LoadingPanelID="LoadingPanel1"/>
             </UpdatedControls>
        </radA:AjaxSetting>
        <radA:AjaxSetting AjaxControlID="ddlEvaluadores">
            <UpdatedControls>
                <radA:AjaxUpdatedControl ControlID="GridEvaluaciones" LoadingPanelID="LoadingPanel1" />
            </UpdatedControls>
        </radA:AjaxSetting>
        <radA:AjaxSetting AjaxControlID="ddlMotivos">
            <UpdatedControls>
                <radA:AjaxUpdatedControl ControlID="GridEvaluaciones" LoadingPanelID="LoadingPanel1" />
            </UpdatedControls>
        </radA:AjaxSetting>
        <radA:AjaxSetting AjaxControlID="btnFiltrarEvaluado">
            <UpdatedControls>
                <radA:AjaxUpdatedControl ControlID="GridEvaluaciones" LoadingPanelID="LoadingPanel1" />
            </UpdatedControls>
        </radA:AjaxSetting>
    </AjaxSettings>
  </radA:RadAjaxManager> 
  <rada:AjaxLoadingPanel style="width:320px;padding-top:20px;" runat="Server" id="LoadingPanel1" InitialDelayTime="0">
    <asp:Image ID="Image1" ImageUrl="~/RadControls/AJAX/Skins/Default/loading2.gif" AlternateText="Loading" BorderWidth="0px" Runat="server"></asp:Image>
  </rada:AjaxLoadingPanel>                
           
        <asp:Label ID="ErrorMessageLabel" EnableViewState="False" runat="server" meta:resourcekey="ErrorMessageLabelResource1" />
</asp:Content>